/**
 * 
 */
package co.edu.udistrital.analyzer.web.webservices;

import java.util.ArrayList;

import javax.jws.WebService;

import org.apache.log4j.Logger;

import co.edu.udistrital.analyzer.newversion.DocumentSearchDto;
import co.edu.udistrital.analyzer.newversion.SearchIndex;

/**
 * The JAX-WS class for the analyzer web service
 * 
 * @author Alejo
 *
 */
@WebService(endpointInterface = "co.edu.udistrital.analyzer.web.webservices.AnalyzerWebService")
public class AnalyzerWebServiceImpl implements AnalyzerWebService {
	
	/**
	 * The log4j Logger
	 */
	private static final Logger LOGGER = Logger.getLogger(AnalyzerWebServiceImpl.class);

	@Override
	public DocumentSearchDto[] search(String newDocumentsIndexDir,
			String keyTerms, float hitsScore) {
		LOGGER.info("Searching... " + newDocumentsIndexDir + " " + keyTerms + " " + hitsScore);
		SearchIndex searcher = new SearchIndex();
		ArrayList<DocumentSearchDto> documents = (ArrayList<DocumentSearchDto>) searcher.searchDocumentsFromIndex(newDocumentsIndexDir, keyTerms, hitsScore);
		LOGGER.info("Found documents: " + documents.size());
		return documents.toArray(new DocumentSearchDto[documents.size()]);
	}


	
}
